<?php
// this is another example showing how the dPFramework is working
// additionally we will have an easy database connection here

// as we are now within the tab box, we have to state (call) the needed information saved in the variables of the parent function
GLOBAL $AppUI, $canRead, $canEdit,$m, $tab;
require_once("classification.class.php");
if (!$canRead) {			// lock out users that do not have at least readPermission on this module
	$AppUI->redirect( "m=public&a=access_denied" );
}
$active = $_POST['active'];
//prepare an html table with a head section
?>
<table class="infopanel" width="100%" cellspacing="0" cellpadding="7" border="0">
<tr>
	<td colspan="100%"><input type="button" class="button" onClick="doEditCls(0)" value="<?php echo $AppUI->_( 'New Classification' );?>"/></td>
	<td align="right">
		<form name="MdClassificationFilter" action="?m=<?=$m?>&tab=<?=$tab?>" method="post">
			<input  class="button" onclick ="this.form.submit()" type="radio" name="active" value="" <?php if ($active == '' || $active== null) echo "checked" ?> /><?=$AppUI->_('All')?>
			<input  class="button" onclick ="this.form.submit()" type="radio" name="active" value="1" <?php if ($active == 1) echo "checked" ?> /> <?=$AppUI->_('Active') ?>
			<input  class="button" onclick ="this.form.submit()" type="radio" name="active" value="0" <?php if ($active == '0') echo "checked" ?> /> <?=$AppUI->_('Disable')?>
		</form>
	</td>
</tr>
</table>
<table id="idTableMasterdata" class="list" width="100%" cellspacing="0" cellpadding="2" border="0">
<tbody>
<tr>

	<th nowrap="nowrap">&nbsp;</th>
	<!--th nowrap="nowrap"><?php echo $AppUI->_( 'Code' );?></th-->
	<th nowrap="nowrap"><?php echo $AppUI->_( 'Name' );?></th>
	<!--th nowrap="nowrap"><?php echo $AppUI->_( 'Type' );?></th-->
	<th nowrap="nowrap"><?php echo $AppUI->_( 'VAT Exemption' );?></th>
	<th nowrap="nowrap"><?php echo $AppUI->_( 'Active' );?></th>
	<th nowrap="nowrap"><?php echo $AppUI->_( 'Delete' );?></th>

</tr>

<?php
// retrieving some dynamic content using an easy database query
// add/show now gradually the einstein quotes
$unitO = new CMdClassification();
$unit = $unitO->loadAllClassification($active);
if (empty($unit)) {?>
<tr class="second">
<td colspan="100"><?php echo $AppUI->_( 'No item available' );?></td>
</tr>
<?php
}
$i = 0;
foreach ($unit as $row) {		//parse the array of einstein quotes
	$i++;
?>
<tr class="<?=($i % 2 == 0) ? "second" : "first" ?>">
	<td nowrap="nowrap" width="20">


	<?php if ($canEdit) {

		echo "\n".'<a onclick="doEditCls('.$row["cls_id"]. ')">';
		echo dPshowImage( 'images/edit.gif' );
		echo "\n</a>";
	}
	?>
	</td>
	<!--td><?php echo $row["cls_code"];?></td-->
	<td><?php echo $row["cls_name"];?></td>
	<!--td><?php //echo $row["type_name"];?></td-->
	<td ><?php if($row["cls_vat_exemption"]==1){ echo dPshowImage( 'images/tick.gif' );}?></td>
	<td ><?php if($row["cls_active"]==1){ echo dPshowImage( 'images/tick.gif' );}?></td>
	<td>
	<?php if ($canEdit) {
		showIconLink('images/delete.gif', 'js:doDelete('.$row["cls_id"]. ', \''.$row["cls_name"].'\')', 'Delete');
	}
	?>
	</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div id="idClsDialog" class="popup" style="visibility: hidden; left: 436px; top: 94.5px; display: none;">
</div>
<script type="text/javascript" src="<?=DP_BASE_URL?>/modules/masterdata/classification/classification.js"></script>
<script type="text/javascript" language="javascript">
	Table("idTableMasterdata").setNormalHover(1);
</script>
<form name="MdFormDelete" id="MdFormDelete" action="?m=masterdata&u=classification" method="post">
	<input type="hidden" name="dosql" value ="do_delete" />
	<input type="hidden" id="del_cc_id" name="cls_id" value ="" />
	<input type="hidden" name="del" value ="" />
</form>